<template>
  <div class="mod-user">
    <avue-crud ref="crud"
               :page="page"
               :data="dataList"
               :option="tableOption"
               @search-change="searchChange"
               @on-load="getDataList">
      <template slot-scope="scope"
                slot="status">
        <el-tag v-if="scope.row.status === 1"
                size="small"
                type="warning">待审核</el-tag>
        <el-tag v-else-if="scope.row.status === 2"
                size="small" type="success">审核通过</el-tag>
        <el-tag v-else-if="scope.row.status === 3"
                size="small" type="danger">不通过</el-tag>
      </template>
    </avue-crud>

  </div>
</template>

<script>
  import { tableOption } from '@/crud/distribution/distribution'
  export default {
    data () {
      return {
        dataList: [],
        dataListLoading: false,
        dataListSelections: [],
        tableOption: tableOption,
        page: {
          total: 0, // 总页数
          currentPage: 1, // 当前页数
          pageSize: 10 // 每页显示多少条
        }
      }
    },
    methods: {
      // 获取数据列表
      getDataList (page, params) {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/distributor/list'),
          method: 'get',
          params: this.$http.adornParams(
            Object.assign(
              {
                current: page == null ? this.page.currentPage : page.currentPage,
                size: page == null ? this.page.pageSize : page.pageSize
              },
              params
            )
          )
        }).then(({ data }) => {
          console.log(data)
          this.dataList = data.records
          this.page.total = data.total
          this.dataListLoading = false
        })
      },
      // 条件查询
      searchChange (params, done) {
        this.getDataList(this.page, params)
        done()
      }
    }
  }
</script>

